<template>
  <div class="row justify-content-center">
    <div class="col-8">
      <form name="editForm" role="form" novalidate v-on:submit.prevent="save()">
        <h2 id="myapplication5App.teacher.home.createOrEditLabel" data-cy="TeacherCreateUpdateHeading">Create or edit a Teacher</h2>
        <div>
          <div class="form-group" v-if="teacher.id">
            <label for="id">ID</label>
            <input type="text" class="form-control" id="id" name="id" v-model="teacher.id" readonly />
          </div>
          <div class="form-group">
            <label class="form-control-label" for="teacher-teacherAccount">Teacher Account</label>
            <input
              type="text"
              class="form-control"
              name="teacherAccount"
              id="teacher-teacherAccount"
              data-cy="teacherAccount"
              :class="{ valid: !$v.teacher.teacherAccount.$invalid, invalid: $v.teacher.teacherAccount.$invalid }"
              v-model="$v.teacher.teacherAccount.$model"
              required
            />
            <div v-if="$v.teacher.teacherAccount.$anyDirty && $v.teacher.teacherAccount.$invalid">
              <small class="form-text text-danger" v-if="!$v.teacher.teacherAccount.required"> This field is required. </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="teacher-teacherName">Teacher Name</label>
            <input
              type="text"
              class="form-control"
              name="teacherName"
              id="teacher-teacherName"
              data-cy="teacherName"
              :class="{ valid: !$v.teacher.teacherName.$invalid, invalid: $v.teacher.teacherName.$invalid }"
              v-model="$v.teacher.teacherName.$model"
            />
          </div>
          <div class="form-group">
            <label class="form-control-label" for="teacher-teacherStatus">Teacher Status</label>
            <input
              type="number"
              class="form-control"
              name="teacherStatus"
              id="teacher-teacherStatus"
              data-cy="teacherStatus"
              :class="{ valid: !$v.teacher.teacherStatus.$invalid, invalid: $v.teacher.teacherStatus.$invalid }"
              v-model.number="$v.teacher.teacherStatus.$model"
            />
          </div>
          <div class="form-group">
            <label class="form-control-label" for="teacher-teacherPassword">Teacher Password</label>
            <input
              type="text"
              class="form-control"
              name="teacherPassword"
              id="teacher-teacherPassword"
              data-cy="teacherPassword"
              :class="{ valid: !$v.teacher.teacherPassword.$invalid, invalid: $v.teacher.teacherPassword.$invalid }"
              v-model="$v.teacher.teacherPassword.$model"
              required
            />
            <div v-if="$v.teacher.teacherPassword.$anyDirty && $v.teacher.teacherPassword.$invalid">
              <small class="form-text text-danger" v-if="!$v.teacher.teacherPassword.required"> This field is required. </small>
            </div>
          </div>
          <div class="form-group">
            <label for="teacher-userClass">User Class</label>
            <select
              class="form-control"
              id="teacher-userClasses"
              data-cy="userClass"
              multiple
              name="userClass"
              v-if="teacher.userClasses !== undefined"
              v-model="teacher.userClasses"
            >
              <option
                v-bind:value="getSelected(teacher.userClasses, userClassOption)"
                v-for="userClassOption in userClasses"
                :key="userClassOption.id"
              >
                {{ userClassOption.id }}
              </option>
            </select>
          </div>
        </div>
        <div>
          <button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" v-on:click="previousState()">
            <font-awesome-icon icon="ban"></font-awesome-icon>&nbsp;<span>Cancel</span>
          </button>
          <button
            type="submit"
            id="save-entity"
            data-cy="entityCreateSaveButton"
            :disabled="$v.teacher.$invalid || isSaving"
            class="btn btn-primary"
          >
            <font-awesome-icon icon="save"></font-awesome-icon>&nbsp;<span>Save</span>
          </button>
        </div>
      </form>
    </div>
  </div>
</template>
<script lang="ts" src="./teacher-update.component.ts"></script>
